Skip to content

Deposit refunds#537

Open
guidanoli wants to merge 3 commits into
next/3.0from
feature/deposit-refunds
Open

Deposit refunds#537
guidanoli wants to merge 3 commits into
next/3.0from
feature/deposit-refunds

Conversation

@guidanoli

@guidanoli guidanoli commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR implements the deposit refunds feature in the contracts. The application contract, once foreclosed, accepts deposit inputs, validates them against the application's input box, decodes them, checks whether they were finalized by the outputs Merkle root validator, and issues refund outputs to the original depositors. This PR also simplifies the retrieval of the input box by removing the data availability byte array in place of a reference to the input box contract. Closes #512.

New deployment

To avoid growing the application contract too much, the refund output building logic was modularized in a separate contract, RefundOutputBuilder, which is deployed as a singleton (like the input box contract) on every supported network. The user shouldn't need to know its address (like the portal contracts) because it is injected in every application contract by the application factory.

Last-processed block number

We have been using the last-processed block number as proxy for the epoch index in the consensus contracts, but now it has another purpose: drawing the line between finalized and non-finalized inputs. This is crucial to deposit refunds, as finalized deposit inputs are assumed to have been processed by the application and refundable through the emergency withdrawal feature (accounts drive). Meanwhile, non-finalized deposit inputs are assumed to not have been processed by the application, and are therefore refundable directly on the base layer.

Breaking changes

With the data availability refactoring, a few breaking changes were introduced in the user-facing IApplicationFactory and ISelfHostedApplicationFactory interfaces. The bytes dataAvailability parameter was replaced with an IInputBox inputBox parameter, both on functions and events. For clients that encoded/decoded the data availability byte array on their side, this change should make deployment easier, as they can simply pass the input box contract directly (or take it from the app deployment event, without decoding). This, of course, restricts apps to using only the input box as source of DA.

Tests

This PR tests refunds for each type of deposit, with randomized depositor addresses, execution-layer data, token IDs and values. It also extensively tests each deposit decoder and refund builder.

Rust bindings

This PR also restricts Rust bindings generation only to a few source contracts. This change aims to circumvent a bug in Forge that generates invalid code for libraries with overloaded external functions (which only affects libraries we only use in tests).

@guidanoli guidanoli added this to the 3.0.0-alpha.7 milestone Jun 25, 2026
@guidanoli guidanoli self-assigned this Jun 25, 2026
@guidanoli guidanoli added A-contracts Area: contracts A-tests Area: tests labels Jun 25, 2026
@guidanoli guidanoli added the A-deployment Area: deployment label Jun 25, 2026
- This commit fixes CI, which produced bindings for test utility
  contracts, which happen to generate invalid Rust code (overloaded
  library function).
@guidanoli guidanoli linked an issue Jun 25, 2026 that may be closed by this pull request
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-contracts Area: contracts A-deployment Area: deployment A-tests Area: tests

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Deposit refunds

1 participant